<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "user".
 *
 * @property integer $id
 * @property string $username
 * @property string $auth_key
 * @property string $password_hash
 * @property string $password_reset_token
 * @property string $email
 * @property integer $role
 * @property integer $status
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $age
 * @property integer $sex
 * @property string $login_ip
 * @property integer $login_time
 * @property string $mobile
 * @property string $name
 */
class User extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['username', 'password_hash'], 'required'],
            [['role', 'status', 'created_at', 'updated_at', 'age', 'sex', 'login_time'], 'integer'],
            [['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
            [['auth_key'], 'string', 'max' => 32],
            [['login_ip', 'mobile'], 'string', 'max' => 20],
            [['name'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'username' => Yii::t('app', '昵称'),
            'auth_key' => Yii::t('app', 'Auth Key'),
            'password_hash' => Yii::t('app', 'Password Hash'),
            'password_reset_token' => Yii::t('app', 'Password Reset Token'),
            'email' => Yii::t('app', '邮箱'),
            'role' => Yii::t('app', '角色'),
            'status' => Yii::t('app', '状态'),
            'created_at' => Yii::t('app', '注册时间'),
            'updated_at' => Yii::t('app', '更新时间'),
            'age' => Yii::t('app', '用户年龄'),
            'sex' => Yii::t('app', '性别'),
            'login_ip' => Yii::t('app', '最后登录IP'),
            'login_time' => Yii::t('app', '最后登录时间'),
            'mobile' => Yii::t('app', '用户手机'),
            'name' => Yii::t('app', '用户昵称'),
        ];
    }
}
